# 1. for in 与while相比,无法自定义循环条件，因为数据集是有限的，不用担心无限循环
i = 0
for x in 'abacadae':
    print(f'{x}', end='')
    if x == 'a':
        i += 1
print(f'：有{i}个a')

# 2.range语句，构建一个数组序列,range(循环0到几),range(开始，结束),range(开始，结束，间隔)
for x in range(1, 6, 4):
    print(x)

# 判断奇偶数
i = 0
j = 0
for x in range(100):
    if x % 2 == 0:
        i += 1
    else:
        j += 1
print(f'有{i}的偶数,{j}个奇数')

for x in range(1, 101):
    for z in range(1, 11):
        print('', end='')

print()
print(f"表白了{x}天")
print(f'总共送了{z * x}朵玫瑰')

# 打印乘法口诀表
for x in range(1, 10):
    for y in range(1, x + 1):
        print(f'{y}*{x}={y * x}\t', end='')
    print()

print('continue,临时中断，当次循环，进入下一次,执行完成后继续往外层执行')
for x in range(1, 6):
    if x == 2:
        continue
    print(x)
print('break,中断当前层次循环，不再进入下一次，代码继续往外层执行')
for x in range(1, 6):
    if x == 2:
        break
    print(x)

print('for循环外层语句')

# 发工资案例:
import random

money = 10000
next_mouth_money = 0
next_mouth_people = ''
for x in range(1, 21):
    num = random.randint(1, 10)
    if num < 5:
        print(f'员工{x},绩效分:{num},低于5，不发工资，下一位')
    else:
        if money <= 0:
            next_mouth_people += f'员工{x}号,'
            next_mouth_money += 1000
            continue
        else:
            money -= 1000
            print(f'向员工{x}发放工资1000元,账户还剩下{money}元')
            print(f'员工{x},工资都发给你了，祝你生活愉快')
print()
print(f'公司账户余额{money}')
if next_mouth_money > 0:
    print(f'{next_mouth_people}公司没钱了，下个月再发给你吧')
    print(f'下个月需要发{next_mouth_money}给{next_mouth_people}')
